import sqlite3

def initialize_database():
    conn = sqlite3.connect('sensor_data.db')
    c = conn.cursor()
    
    # 创建温湿度记录表
    c.execute('''CREATE TABLE IF NOT EXISTS sensor_data
                 (id INTEGER PRIMARY KEY AUTOINCREMENT,
                 timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
                 temperature REAL NOT NULL,
                 humidity REAL NOT NULL,
                 smoke INTEGER DEFAULT 0)''')
    
    # 创建图片元数据表
    c.execute('''CREATE TABLE IF NOT EXISTS image_metadata
                 (id INTEGER PRIMARY KEY AUTOINCREMENT,
                 timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
                 image_path TEXT NOT NULL)''')
    
    conn.commit()
    conn.close()

if __name__ == "__main__":
    initialize_database()